package cn.yunhe.service;

import cn.yunhe.dao.IAdminDao;
import cn.yunhe.entity.Admin;
import cn.yunhe.util.SqlSessionFactoryUtil;
import net.sf.json.JSONArray;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class AdminService {
    SqlSession session= null;
    IAdminDao iAdminDao=null;
    public JSONArray searchAdmin(){
        List<Admin> list=null;
        JSONArray jsonArray=new JSONArray();
        try {
            session=SqlSessionFactoryUtil.getSqlSession();
            iAdminDao=session.getMapper(IAdminDao.class);
            list=iAdminDao.searchAdmin();
            jsonArray=JSONArray.fromObject(list);
        }finally {
            session.close();
        }
        return jsonArray;
    }
}
